package com.geez.bbl.ti2latin;

import com.geez.bbl.db.type.BblBook;
import com.geez.bbl.db.type.Builder;
import com.geez.bbl.db.type.SqlGenerator;
import com.geez.bbl.pdf.Bbl2Pdf;
import com.geez.bbl.util.FileUtils;
import com.geez.bbl.util.GeezUtil;
import com.geez.bbl.util.ProjectResources;
import com.geez.bbl.util.Transformer;
import com.geez.bbl.wordlist.WordList;

import java.util.List;

/**
 * @author biniam.gebremichael
 * @since 3/2/12
 */
public class LatinBookBuilder {

    //edit
    private static String language = "am";
    private static String version = "";

    //do not edit
    private static String table = language+version+"_bible";
    private static String seraTable = language+"s"+version+"_bible";
    private static String seraNoVowelTable = language+"v"+version+"_bible";
    private static String wordListTable = language+version+"_wordlist";

    public static void main(String[] args) throws Exception {
        LatinBookBuilder latinBookBuilder = new LatinBookBuilder();
        List<BblBook> seraBook = new Builder(language, table, latinBookBuilder.new ToSera()).build();
        FileUtils.save(ProjectResources.getResourceFile(seraTable+".sql"), SqlGenerator.toSql(seraBook, seraTable));
        List<BblBook> seraNoVowelBook = new Builder(language, table, latinBookBuilder.new SeraNoVowel()).build();
        FileUtils.save(ProjectResources.getResourceFile(seraNoVowelTable+".sql"), SqlGenerator.toSql(seraNoVowelBook, seraNoVowelTable));
        List<BblBook> geezBook = new Builder(language, table).build();
        FileUtils.save(ProjectResources.getResourceFile(wordListTable+".sql"), new WordList().toSql(wordListTable, geezBook));
        List<BblBook> books = new Builder("ti").build();
        new Bbl2Pdf().createPdf(books);
    }

    class ToSera implements Transformer<String, String> {
        @Override
        public String transform(String s) {
            return GeezUtil.toSera(s);
        }
    }

    class SeraNoVowel implements Transformer<String, String> {
        @Override
        public String transform(String s) {
            return GeezUtil.removeVowel(GeezUtil.toSera(s));
        }
    }

}
